<?php

namespace App\Models\Site;

use Dcat\Admin\Traits\HasDateTimeFormatter;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\SiteApp
 *
 * @property int $id ID
 * @property string|null $version 版本
 * @property int|null $code 代码
 * @property int|null $platform 平台1=安卓2=ios
 * @property string|null $summary 更新内容
 * @property string|null $download 下载地址
 * @property \Illuminate\Support\Carbon|null $created_at 创建时间
 * @property \Illuminate\Support\Carbon|null $updated_at 更新时间
 * @property \Illuminate\Support\Carbon|null $deleted_at 删除时间
 * @property int|null $status 状态
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp newQuery()
 * @method static \Illuminate\Database\Query\Builder|SiteApp onlyTrashed()
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp query()
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereCode($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereDeletedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereDownload($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp wherePlatform($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereStatus($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereSummary($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|SiteApp whereVersion($value)
 * @method static \Illuminate\Database\Query\Builder|SiteApp withTrashed()
 * @method static \Illuminate\Database\Query\Builder|SiteApp withoutTrashed()
 * @mixin \Eloquent
 */
class SiteApp extends \App\Models\BasicModel
{
	use HasDateTimeFormatter;
    use SoftDeletes;

    protected $table = 'site_app';

    protected $fields = ['id', 'version', 'code', 'platform', 'port_type', 'summary', 'download', 'status'];
    /**
     * @param $platform
     * @param $type
     * @param $code
     * @return SiteApp|\Illuminate\Database\Eloquent\Builder|Model|\Illuminate\Database\Query\Builder|object|null
     */
    public function getNew($port_type, $code)
    {
        $where['port_type'] = $port_type;
        return self::where($where)->where('code', '>', $code)->select($this->fields)->first();
    }
}
